import i18n from "../i18n/index"
import type { FormRules } from 'element-plus'
import {phoneNumOrEmailRule} from "./common"
// tabs的类型
export enum TabsListEnum {
    // eslint-disable-next-line
    Login = "login",
    // eslint-disable-next-line
    Msg = "msg"
}

// 定义密码登录form表单数据格式
export class PasswordRouleForm {
    phoneNum: string = "" // 手机号
    password: string = "" // 密码
    isChecked: string[] = [] // 是否阅读协议
}

// 定义短信登录form表单数据格式
export class MsgRouleForm {
    phoneNum: string = "" // 手机号
    mgs: string = "" // 短信
    isChecked: string[] = [] // 是否阅读协议
}

// 密码登录表单校验
export const PasswordRouleFormData:FormRules<PasswordRouleForm> = {
    phoneNum: phoneNumOrEmailRule,
    password: [
        { required: true, message: i18n.global.t("login_password_required"), trigger: 'blur' },
        {
            validator: (rule:any, value: any, callback: any) => {
                if (value === "") {
                    callback()
                } else if (value.trim().length < 6 || value.trim().length > 16) {
                    callback(i18n.global.t("register_form_register_password1Rule2"))
                }else {
                    callback()
                }
            }
        }
    ],
    isChecked: [
        {
            type: "array",
            required: true,
            message: i18n.global.t("login_readTheAgreement_tips"),
            trigger: 'change',
        }
    ]
}

// 短信登陆表单校验
export const MsgRouleFormData:FormRules<MsgRouleForm> = {
    phoneNum: phoneNumOrEmailRule,
    mgs: [
        { required: true, message: i18n.global.t("login_msg_required"), trigger: 'blur' },
    ],
    isChecked: [
        {
            type: "array",
            required: true,
            message: i18n.global.t("login_readTheAgreement_tips"),
            trigger: 'change',
        }
    ]

}

// 倒计时信息
export const countdownData = {
    second: 60,
    buttonName: i18n.global.t("login_getSms_btn"),
    isDisabled: false,
}

